package com.baor.web.controller.order;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baor.common.annotation.Log;
import com.baor.common.core.controller.BaseController;
import com.baor.common.core.domain.AjaxResult;
import com.baor.common.enums.BusinessType;
import com.baor.order.domain.TRight;
import com.baor.order.service.ITRightService;
import com.baor.common.utils.poi.ExcelUtil;
import com.baor.common.core.page.TableDataInfo;

/**
 * 维权Controller
 * 
 * @author ruoyi
 * @date 2025-07-18
 */
@RestController
@RequestMapping("/order/right")
public class TRightController extends BaseController
{
    @Autowired
    private ITRightService tRightService;

    /**
     * 查询维权列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TRight tRight)
    {
        startPage();
        List<TRight> list = tRightService.selectTRightList(tRight);
        return getDataTable(list);
    }
    @GetMapping("/selectTRightEndList")
    public TableDataInfo selectTRightEndList(TRight tRight)
        {
        startPage();
        List<TRight> selectTRightEndList = tRightService.selectTRightEndList(tRight);
        return getDataTable(selectTRightEndList);
    }
    @GetMapping("/selectTRightBuyerList")
    public TableDataInfo selectTRightBuyerList(TRight tRight)
        {
        startPage();
        List<TRight> selectTRightBuyerList = tRightService.selectTRightBuyerList(tRight);
        return getDataTable(selectTRightBuyerList);
    }
    @GetMapping("/selectTRightSellerList")
    public TableDataInfo selectTRightSellerList(TRight tRight)
        {
        startPage();
        List<TRight> selectTRightSellerList = tRightService.selectTRightSellerList(tRight);
        return getDataTable(selectTRightSellerList);
    }
    @GetMapping("/selectTRightSellerRejectList")
    public TableDataInfo selectTRightSellerRejectList(TRight tRight)
        {
        startPage();
        List<TRight> selectTRightSellerRejectList = tRightService.selectTRightSellerRejectList(tRight);
        return getDataTable(selectTRightSellerRejectList);
    }

    /**
     * 导出维权列表
     */
    @Log(title = "维权", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TRight tRight)
    {
        List<TRight> list = tRightService.selectTRightList(tRight);
        ExcelUtil<TRight> util = new ExcelUtil<TRight>(TRight.class);
        util.exportExcel(response, list, "维权数据");
    }

    /**
     * 获取维权详细信息
     */
    @GetMapping(value = "/{rightId}")
    public AjaxResult getInfo(@PathVariable("rightId") Long rightId)
    {
        return success(tRightService.selectTRightByRightId(rightId));
    }

    /**
     * 新增维权
     */

    @Log(title = "维权", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TRight tRight)
    {
        return toAjax(tRightService.insertTRight(tRight));
    }

    /**
     * 修改维权
     */
    @PreAuthorize("@ss.hasPermi('order:right:edit')")
    @Log(title = "维权", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TRight tRight)
    {
        return toAjax(tRightService.updateTRight(tRight));
    }

    /**
     * 删除维权
     */
    @PreAuthorize("@ss.hasPermi('order:right:remove')")
    @Log(title = "维权", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rightIds}")
    public AjaxResult remove(@PathVariable Long[] rightIds)
    {
        return toAjax(tRightService.deleteTRightByRightIds(rightIds));
    }
}
